package com.wei.youvie.mapper;

import com.wei.youvie.model.entity.Space;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author Youvie
* @description 针对表【space(空间)】的数据库操作Mapper
* @createDate 2025-04-15 19:11:55
* @Entity com.wei.youvie.model.entity.Space 实体
*/
public interface SpaceMapper extends BaseMapper<Space> {

    /**
     * 获取使用空间最大的前N个空间信息
     *
     * @param topN 获取前N个空间信息
     * @return 包含前N个空间信息的列表
     */
    @Select("select id, spaceName, userId, totalSize" +
            " from space " +
            " order by totalSize desc " +
            " limit #{topN}")
    List<Space> getTopNSpaceUsage(int topN);


    @Delete("delete from space where userId = #{userId}")
    int deleteBySpaceId(Long userId);
}




